package o;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.huawei.appgallery.agreement.api.ui.ITermsActivityProtocol;
import huawei.widget.HwButton;
import huawei.widget.HwTextView;
import java.lang.ref.WeakReference;
import o.axa.b;
import o.axa.f;
import o.axa.h;

public class axs extends evx {
    private View ʽ;
    cks ˊ;
    private WeakReference<Context> ˋ;
    private HwTextView ˎ;
    private axq ˏ;
    private CheckBox ॱ;

    static class c extends axs {
        c(Activity activity) {
            super(activity, null);
            awg.ˎ.ˋ("ProtocolAlertDialog", "DumbProtocolAlertDialog nothing to do.");
        }
    }

    axs(Activity activity, @Nullable ITermsActivityProtocol iTermsActivityProtocol) {
        this.ˋ = new WeakReference(activity);
        int viewType = iTermsActivityProtocol == null ? 0 : iTermsActivityProtocol.getViewType();
        this.ʽ = ˏ(viewType);
        if (viewType == 1) {
            axq o_axr = new axr(activity);
            o_axr.setCanceledOnTouchOutside(false);
            o_axr.setOnCancelListener(new OnCancelListener(this) {
                final /* synthetic */ axs ˎ;

                {
                    this.ˎ = r1;
                }

                public void onCancel(DialogInterface dialogInterface) {
                    if (this.ˎ.ˊ != null) {
                        this.ˎ.ˊ.upgrade();
                    }
                }
            });
            this.ˏ = o_axr;
        } else {
            this.ˏ = new axl(activity, null);
        }
        if (this.ʽ != null) {
            ˊ(this.ʽ, viewType);
            this.ˏ.ॱ(this.ʽ);
        }
    }

    static axs ˎ(Activity activity, @Nullable ITermsActivityProtocol iTermsActivityProtocol) {
        if (activity.isFinishing()) {
            return new c(activity);
        }
        return new axs(activity, iTermsActivityProtocol);
    }

    void ˊ(cks o_cks) {
        this.ˊ = o_cks;
    }

    void ॱ() {
        if (this.ˏ != null) {
            try {
                this.ˏ.dismiss();
            } catch (IllegalArgumentException e) {
                awg.ˎ.ˎ("ProtocolAlertDialog", "dlProgressDialog dismiss IllegalArgumentException");
            }
            this.ˏ = null;
        }
    }

    private View ˏ(int i) {
        Context context = (Context) this.ˋ.get();
        if (context == null) {
            awg.ˎ.ˊ("ProtocolAlertDialog", "getContentView missing mContext, viewType = " + i);
            return null;
        }
        LayoutInflater from = LayoutInflater.from(context);
        if (i != 1) {
            return from.inflate(f.ˋॱ, null);
        }
        if (((double) epv.ॱ(context)) * 0.6d > ((double) epv.ˋ(context, 458))) {
            return from.inflate(f.ᐝॱ, null);
        }
        return from.inflate(f.ॱˋ, null);
    }

    private void ˊ(View view, int i) {
        azb.ˏ(view);
        HwButton hwButton = (HwButton) view.findViewById(b.ˈ);
        hwButton.setText(h.ʻॱ);
        hwButton.setOnClickListener(this);
        hwButton = (HwButton) view.findViewById(b.ʾ);
        hwButton.setText(h.ॱॱ);
        hwButton.setOnClickListener(this);
        this.ॱ = (CheckBox) view.findViewById(b.ʻॱ);
        awx ʻ = axg.ˏ().ʻ();
        ((ImageView) view.findViewById(b.ॱˎ)).setImageResource(ʻ.ˏ());
        ((TextView) view.findViewById(b.ʽॱ)).setText(ʻ.ॱॱ());
        ((TextView) view.findViewById(b.ᐝॱ)).setText(ʻ.ʼ());
        TextView textView = (TextView) view.findViewById(b.ॱˋ);
        if (i == 1) {
            textView.setText(ʻ.ˊ());
        } else {
            textView.setText(ʻ.ʽ());
        }
        ((ImageView) view.findViewById(b.ʼॱ)).setImageResource(ʻ.ᐝ());
        this.ˎ = (HwTextView) view.findViewById(b.ॱᐝ);
    }

    public void ˋ(View view) {
        if (view.getId() == b.ʾ) {
            awg.ˎ.ˋ("onSingleClick", "cancel");
            ॱ();
            if (this.ˊ != null) {
                this.ˊ.upgrade();
            }
        } else if (view.getId() == b.ˈ) {
            awg.ˎ.ˋ("onSingleClick", "confirm");
            ॱ();
            if (this.ˊ != null) {
                this.ˊ.enableNetworking();
            }
        }
    }

    CheckBox ˋ() {
        if (this.ॱ != null) {
            return this.ॱ;
        }
        awg.ˎ.ˊ("ProtocolAlertDialog", "getPushCheckBox missing mCheckBox");
        return null;
    }

    HwTextView ˎ() {
        return this.ˎ;
    }
}
